import { legacy_createStore,combineReducers,compose,applyMiddleware } from 'redux'     // createStore已经弃用，更换成了legacy_createStore
// 引入 redux-thunk，让仓库中能够执行异步操作
import reduxThunk from "redux-thunk"
// 引入两个reducer模块
import handleNumReducer from './NumStatus/reducer.ts'
import handleArrReducer from './ArrStatus/reducer.ts'

// 利用 combineReducers 钩子将两个reducer仓库模块合并起来
const reducers = combineReducers({
    handleNumReducer,
    handleArrReducer
})

// window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 的作用是让浏览器正常使用redux-dev-tools插件
// const store = legacy_createStore(reducers,window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())

// 判断有没有__REDUX_DEVTOOLS_EXTENSION_COMPOSE__这个模块
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}):compose //rt

// 创建仓库
// 把仓库数据reducers，浏览器插件redux-dev-tools，还有reduxThunk插件关联在仓库store中
const store = legacy_createStore(reducers,composeEnhancers(applyMiddleware(reduxThunk))); 

// 将仓库对外默认暴露
export default store